package com.bwie.controller;

import com.bwie.common.domain.Business;
import com.bwie.common.domain.Follow;
import com.bwie.common.domain.Keep;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.service.BusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @className: BusinessController
 * @Description: TODO
 * @version: v1.８.0
 * @author: GONGWENXUE
 * @date: 2025/10/10 11:19
 */
@CrossOrigin
@RestController
@RequestMapping("buss")
public class BusinessController {
    @Autowired
    BusinessService businessService;
    /**
     * 商机列表
     */
    @PostMapping("bussList")
    public Result<PageResult<Business>> bussList(@RequestBody Business business){
        PageHelper.startPage(business.getPageNum(),business.getPageSize());
        List<Business> businessList=businessService.bussList(business);
        PageInfo<Business> businessPageInfo = new PageInfo<>(businessList);
        return PageResult.toResult(businessPageInfo.getTotal(),businessList);
    }
    /**
     * 新增商机信息
     */
    @PostMapping("addBuss")
    public Result<Integer> addBuss(@RequestBody Keep keep){
        Integer n=businessService.addBuss(keep);
        return Result.success(n);
    }
//    /**
//     * 新增跟进信息
//     */
//    @PostMapping("addFollow")
//    public Result<Integer> addFollow(@RequestBody Follow follow){
//        Integer m=businessService.addFollow(follow);
//        return Result.success(m);
//    }
    /**
     * 图片上传
     */
    @PostMapping("upload")
    public Result<String> upload(@RequestParam("file") MultipartFile[] multipartFiles){
        String s=businessService.upload(multipartFiles);
        return Result.success(s);
    }
    @GetMapping("/myBusinessesWithRemind")
    public List<Business> getMyBusinessesWithRemind(Long businessId) {
        return businessService.getMyBusinessesWithRemind(businessId);
    }
}